package com.wufei.tastefor.adapter;

import android.content.Context;
import android.net.Uri;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.wufei.tastefor.R;
import com.wufei.tastefor.bean.HotPeople;

import java.util.List;

/**
 * Created by wbcomputer on 2015/11/11.
 */
public class HotPeopleAdapter extends RecyclerView.Adapter<HotPeopleAdapter.MyViewHolder> {
    private List<HotPeople> list;
    private Context context;

    public HotPeopleAdapter(List<HotPeople> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public HotPeopleAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(context).inflate(R.layout.item_jingying_recycle_layout, parent, false);

        MyViewHolder holder = new MyViewHolder(itemView);

        return holder;
    }

    @Override
    public void onBindViewHolder(HotPeopleAdapter.MyViewHolder holder, int position) {
        HotPeople people = list.get(position);
        holder.imageView.setImageURI(Uri.parse(people.getPeopleIcon()));
        holder.username.setText(people.getPeopleName());
        //holder.checkBox
    }

    @Override
    public int getItemCount() {
        return list == null ? 0 : list.size();
    }

    public class MyViewHolder extends RecyclerView.ViewHolder {

        private SimpleDraweeView imageView;
        private TextView username;
        private CheckBox checkBox;

        public MyViewHolder(View view) {
            super(view);
            imageView = (SimpleDraweeView) view.findViewById(R.id.item_jingying_photo);
            username = (TextView) view.findViewById(R.id.item_jingying_username);
            checkBox = (CheckBox) view.findViewById(R.id.item_jingying_checkbox);
        }
    }
}
